<!DOCTYPE html>
<html style="height: 8rem;">

<head> 
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../../css/aui.css">
    <link rel="stylesheet" type="text/css" href="../../css/aui-slide.css">
    <link rel="stylesheet" type="text/css" href="../../css/api.css">
    <link rel="stylesheet" type="text/css" href="../../font-icon/demo.css">
    <link rel="stylesheet" type="text/css" href="../../font-icon/iconfont.css">
    <script type="text/javascript" src="../../script/api.js"></script>
</head>

<body style="background-color: #ff9f00;z-index: 0;">
    <div class="aui-content-padded aui-margin-t-10" id="content" style="width: 96%;margin-left: 2%;">

    </div>
    <div class="aui-card-list-footer aui-text-center" id="refresh" style="display:none;">
        <span>下拉加载更多</span>
    </div>
</body>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">
    apiready = function() {
        j = 0;
        arr = new Array();
        arr1 = new Array();
        var arr2 = new Array();
        post_list();

        function post_list() {
            var body = {
                token: $api.getStorage('token'),
                j: j
            };
            api.ajax({
                url: 'http://www.mk517.com/webApi/youquans.php',
                method: 'post',
                "headers": {
                    "Content-Type": "application/json"
                },
                dataType: 'json',
                data: {
                    body: body
                }
            }, function(ret, err) {
                //alert(JSON.stringify(ret));
                if (ret) {
                    console.log(ret[0].post_picture);
                    if (!ret.info && ret.length > 0) {
                        $api.byId('content').innerHTML = '';
                        for (var i = 0; i < ret.length; i++) {
                            data = ret[i];
                            str = 'change_status' + i;
                            arr.push(data.id);
                            arr1.push(data.tieid);
                            laud = 'laud' + i;
                            str1 = 'hotIcon' + i
                            data.post_state % 2 == 0 ? status = '+关注' : status = '已关注';
                            (data.post_picture != null && data.post_picture != '') ? (imgAddress = '<div style="width:auto;height:auto; background-color: red;" onclick="openPostInfo(' + data.tieid + ',' + data.id + ')"><img src="' + data.post_picture +
                                '" id="picture1" style="width:100%;height:auto;max-width:100%;max-height:100%;overflow:hidden;"></div>') : imgAddress = '';
                            $api.byId('content').innerHTML +=
                                '<div class="aui-card-list aui-content">' +
                                '<div class="aui-card-list-header aui-card-list-user "  >' +
                                '<div class="aui-card-list-user-avatar" >' + 
                                '<img id="post_user_avater"  src="' + data.post_user_avater + '" class="aui-img-round" />' +
                                '</div>' +
                                '<div class="aui-card-list-user-name">' +
                                '<div id="post_username">' + data.post_username + '<i id="' + str1 + '" class="icon iconfont" ></i></div>' +
                                '<div style="position: absolute; margin-top:0.75rem;height:0rem;margin-left: 0rem;font-family: SimHei;color: #787878;font-size: 0.75rem;line-height:0.8rem;">'+'上午9:30'+'</div>'+
                                '<span  class="aui-btn aui-btn-warning" id="' + str + '" onclick="change(' + i + ',' + data.id + ',' + data.post_state + ');">' + status + '</span>' +
                                '</div>' +'<div class="aui-down" >'+' <i class="aui-iconfont aui-icon-down">'+'</i>'+'</div> '+
                                '</div>' +
                                '<div class="">' +
                                '<p id="post_goods_content" onclick="openPostInfo(' + data.tieid + ',' + data.id + ')">' + data.post_goods_content + '</p>' +
                                imgAddress +
                                '</div>' +
                                '<div class="aui-card-list-footer aui-border-t" >' +
                                '<div id="post_star_count"><i class="aui-iconfont aui-icon-share" onclick="sharePost(' + i + ');"></i>' +'</div>'+
                                '<div id="post_laud_count"><i id="' + laud + '" class="aui-iconfont aui-icon-laud" onclick="postLaud(' + i + ',' + data.tieid + ')">' + data.post_laud_count + '</i></div>' +
                                '<div id="post_note_count"><i class="aui-iconfont aui-icon-comment" id="note" onclick="postComment(' + data.tieid + ',' + data.id + ')">' + data.post_note_count + '</i></div>'  +
                                '<div id="post_star_count"><i class="icon iconfont icon-hongbao" onclick="postMon(' + data.id + ',' + data.tieid + ')">' + data.post_reward + '</i>' +'</div>'+
                                '</div>'
                                +'</div></div>';
                            if (data.host == 1) {
                                $api.addCls($api.byId(str1), 'icon-huo')
                            };
                            if (status == "已关注") {
                                $api.removeCls($api.byId(str), 'aui-btn-warning');
                            };
                        }
                    }
                    // changeIndexFrame(0);
                    // alert(JSON.stringify(ret));
                } else {
                    //alert(JSON.stringify(err));
                }
            });
        }

        refresh(post_list);

        /* 下拉刷新頁面 */
        api.setRefreshHeaderInfo({
            visible: true,
            // loadingImg: 'widget://image/refresh.png',
            bgColor: '#ff9f00',
            textColor: '#fff',
            textDown: '下拉刷新...',                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
            textUp: '松开刷新...',
            showTime: true
        }, function(ret, err) {
            window.location.reload();
            api.refreshHeaderLoadDone();
        });

        var k=1;
        window.doMore = function(){
           
            k=k+1;
            if(k%2==0){
                 $('#more_thing').css('display','block');
            }else{
                $('#more_thing').css('display','none');

            }
        }
        
    }

    
</script>

</html>